function outString = fixTexStyle(inString)
% function outString = fixTexStyle(inString)
%
% Given an input string, will put slashes before underscores and carrots so
% as to allow the output in, for example, a MATLAB title to look normal.
%
% Created 8/8/2014 by TM

%% Check to make sure String
if ~ischar(class(inString))
    warning('Cannot fix Tex style of non-strings')
    return
end
%% Underscores
undloc = regexp(inString,'_');
for j = undloc
    inString = [inString(1:j-1) '\_' inString(j+1:end)];
end

%% Carrots
carloc = regexp(inString,'^');
for j = carloc
    inString = [inString(1:j-1) '\_' inString(j+1:end)];
end

%% Create Nice String
outString = inString;

end